package com.example.lijinyuan.baseandroid;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.example.lijinyuan.baseandroid.Activity.ActivityLife;
import com.example.lijinyuan.baseandroid.Activity.SingleInstance;
import com.example.lijinyuan.baseandroid.Activity.SingleTask;
import com.example.lijinyuan.baseandroid.Activity.SingleTop;
import com.example.lijinyuan.baseandroid.Activity.Standard;
import com.example.lijinyuan.baseandroid.BroadcastReceive.Broadcast;
import com.example.lijinyuan.baseandroid.Intent.ExplicitIntent;
import com.example.lijinyuan.baseandroid.Intent.ImplicitIntent;
import com.example.lijinyuan.baseandroid.Service.BindService;
import com.example.lijinyuan.baseandroid.Service.StartService;

import java.util.ArrayList;


public class MainActivity extends ActionBarActivity {

    ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        listView = (ListView) findViewById(R.id.choose_list);

        ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, getData());
        listView.setAdapter(arrayAdapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch (position) {
                    case 0:
                        startActivity(new Intent(MainActivity.this, ActivityLife.class));
                        break;
                    case 1:
                        startActivity(new Intent(MainActivity.this, Standard.class));
                        break;
                    case 2:
                        startActivity(new Intent(MainActivity.this, SingleTask.class));
                        break;
                    case 3:
                        startActivity(new Intent(MainActivity.this, SingleTop.class));
                        break;
                    case 4:
                        startActivity(new Intent(MainActivity.this, SingleInstance.class));
                        break;
                    case 5:
                        startActivity(new Intent(MainActivity.this, ImplicitIntent.class));
                        break;
                    case 6:
                        startActivity(new Intent(MainActivity.this, ExplicitIntent.class));
                        break;
                    case 7:
                        startActivity(new Intent(MainActivity.this, BindService.class));
                        break;
                    case 8:
                        startActivity(new Intent(MainActivity.this, StartService.class));
                        break;
                    case 9:
                        startActivity(new Intent(MainActivity.this, Broadcast.class));
                        break;
                }
            }
        });
    }


    public ArrayList<String> getData() {
        ArrayList<String> list = new ArrayList<String>();
        list.add("ActivityLife");
        list.add("StandardActivity");
        list.add("SingleTaskActivity");
        list.add("SingTopActivity");
        list.add("SingTaskActivity");
        list.add("ImplicitIntent");
        list.add("ExplicitIntent");
        list.add("BindService");
        list.add("StartService");
        list.add("StartBroadcast");
        return list;
    }

}
